﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DotNet.Sqlite
{
    public partial class TableListFrm : Form
    {
        private DBBLL bll = new DBBLL();
        public TableListFrm()
        {
            InitializeComponent();
        }

        private void btn_TestDB_Click(object sender, EventArgs e)
        {
            if (DBBLL.TestDbConnect())
            {
                MessageBox.Show("测试连接成功！");
            }
            else
            {
                MessageBox.Show("测试连接失败！");
            }
        }

        /// <summary>
        /// 执行自定义sql语句
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbtn_EXEC_Click(object sender, EventArgs e)
        {
            try
            {
                this.dgv_TmpResult.DataSource = SQLiteHelper.ExecuteDataSet(DBBLL.GetDbConStr(), this.txt_Sqlcmd.Text, null).Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
